<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="./css/luckState.css">
    <title>2021少数民族传统体育竞技</title>
</head>

<body>
    <div class="layout">
        <img src="http://qrwbtqqjh.hn-bkt.clouddn.com/game1_9.png" alt="" class="bg-img">
        <img src="./img/back_btn.png" alt="" class="back-btn">
        <img src="./img/fail_img.png" alt="" class="fail-img">
        <div class="state-text-box">
            <p class="success-text">恭喜获得</p>
            <p class="success-text amount"></p>
        </div>
        <img src="./img/success_box.png" alt="" class="box-img">
        <img src="./img/again_icon.png" alt="" class="icon again">
        <img src="./img/next_icon.png" alt="" class="icon next">
        <img src="./img/skill_icon.png" alt="" class="icon">
    </div>


    <script src="./js/jquery.js"></script>
    <script src="./js/request.js"></script>
    <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

    <script>
        request('get_share_sign/', {
            zm_token: localStorage.user_token,
            _zm_post_type: 'ajax',
            url: location.href
        }).then(res => {
            wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: res.rsm.appId, // 必填，公众号的唯一标识
                timestamp: res.rsm.timestamp, // 必填，生成签名的时间戳
                nonceStr: res.rsm.nonceStr, // 必填，生成签名的随机串
                signature: res.rsm.signature, // 必填，签名
                jsApiList: ['onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone',
                    'onMenuShareTimeline',
                    'updateAppMessageShareData',
                    'hideOptionMenu',
                    'showOptionMenu',
                    'hideMenuItems',
                    'showMenuItems',
                    'hideAllNonBaseMenuItem',
                    'showAllNonBaseMenuItem',
                ] // 必填，需要使用的JS接口列表
            });
            wx.ready(function () { //需在用户可能点击分享按钮前就先调用
                wx.hideAllNonBaseMenuItem();
            });
        })
        // 记得清除
        let progress = localStorage.getItem('progress')
        if (progress == 3) {
            $('.next').hide()
        }

        (function ($) {
            $.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }
        })(jQuery);
        let state = $.getUrlParam('state');
        let amount = $.getUrlParam('amount');

        let success = state // 是否抽到奖品

        $('.back-btn').on('click', function () {
            location.href = 'http://youxi.haiqikj.com/chooseGame.html'
        })

        if (success) {
            $('.fail-img').hide()
            $('.amount').text(`${amount}`)
        } else {
            $('.fail-img').show()
            $('.box-img').hide()
            $('.state-text-box').html('<p class="fail-text">未抽中奖品</p>')
        }

        if (JSON.parse(`${localStorage.getItem(`game${localStorage.getItem('progress')}`)}`).active && progress != 3) {
            $('.next').show()
        } else {
            $('.next').hide()
        }

        $('.again').on('click', function() {
            location.href = 'http://youxi.haiqikj.com/index.html'
        })

        $('.next').on('click', function() {
            // location.href = 'http://youxi.haiqikj.com/./game2.html'
            // 记得清除
            location.href = `game${(localStorage.getItem('progress') | 0) + 1}.html`
            localStorage.setItem('progress', progress == 3 ? 3 : progress + 1)
        })
    </script>
</body>

</html>